package lightswitch.server.code.extendedcontrol;

import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

public class MyTreeCellRenderer extends DefaultTreeCellRenderer {
    @Override
    public Component getTreeCellRendererComponent(JTree tree,
            Object value, boolean selected, boolean expanded,
            boolean leaf, int row, boolean hasFocus){

            super.getTreeCellRendererComponent(tree, value,
            selected, expanded, leaf, row, hasFocus);

            int level = ((DefaultMutableTreeNode) value).getLevel();
            JLabel label = (JLabel) this ;
            if(level == 0) {
                label.setIcon( new ImageIcon("database.png") ) ;
            }else if(level == 1) {
                label.setIcon( new ImageIcon("table.png") ) ;
            }
            return this;
        }
}
